import Vue from "vue";
import Router from "vue-router";
const ReportDownloadDetail = () => import("views/evaluateCenter/evaluateManage/reportDownload");
import moduleRoutes from "./dynamicRoutes";
Vue.use(Router);

export const constantRoutes = [
  {
    path: "/",
    redirect: "/property",
    hidden: true,
  },
  {
    path: "/demo",
    component: () => import("@/demo"),
    hidden: true,
  },
  {
    path: "/evaluate/manage/reportDownload",
    hidden: true, //这个写true 就不会出现两个层级了
    component: ReportDownloadDetail,
  },
  {
    path: "/question",
    name: "question",
    hidden: true,
    component: () => import("@/views/questionnaire/questionnaire"),
  },
  {
    path: "/consult/config",
    name: "consultConfig",
    hidden: true,
    component: () => import("views/consultCenter/record/config"),
    meta: { title: "咨询记录", icon: "el-icon-service" },
  },
  {
    path: "/403",
    component: () => import("@/views/403"),
    hidden: true,
  },
  {
    path: "/404",
    component: () => import("@/views/404"),
    hidden: true,
  },
  // 404 page must be placed at the end !!!
  // { path: "*", redirect: "/404", hidden: true },
];
const createRouter = () => {
  let moduleRouteArr = [];
  for (let key in moduleRoutes) {
    moduleRouteArr.push(...moduleRoutes[key]);
  }
  console.log(moduleRouteArr);
  return new Router({
    mode: "history", // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: [...moduleRouteArr, ...constantRoutes],
  });
};
const router = createRouter();
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
